/**
 * 
 */
package ua.kpi.javatrainee6.model.departments;

import java.util.Date;

/**
 * Abstract class for university section
 * Extended by Group and University classes
 */
public abstract class Department {
	
	private static int id = 0;
	private String title;
	private Date creationDate;
	
	/**
	 * Main constructor
	 */
	public Department(String title, Date creationDate) {
		this.title = title;
		this.creationDate = creationDate;
	}
	
	/**
	 * Optional constructor, used now for automatic data generation
	 * Generating departments like this: {"department1", Date1}, {"department2", Date2} ...
	 * Will be deleted in later versions - when files or databases with data will be added...
	 */
	public Department() {
		id++;
		title = "department" + id;
		creationDate = new Date();
	}
	
	/** these methods will be implemented in Group and University classes */
	abstract void viewAllSections();
	abstract void viewAllMembers();
	abstract void viewAllSubjects();
	
	public String getTitle() {
		return title;
	}
	
	@Override
	public String toString() {
		return String.format("Title: %s, Creation Date: %tF", title, creationDate);
	}
	
	@Override
	public boolean equals(Object otherObject) {
		if (this == otherObject) {
			return true;
		}
		if (otherObject == null) {
			return false;
		}
		if (getClass() != otherObject.getClass()) {
			return false;
		}
		Department other = (Department) otherObject;
		return (title.equals(other.title) && (creationDate.compareTo(other.creationDate) == 0));         
	}
}

